/*
 * Created on May 22, 2004
 *
 * Vectrics Inc.  GNU Public License.
 */
package org.vectrics.recruiter.struts.admin;

import javax.servlet.jsp.JspException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.vectrics.domain.Domain;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.recruiter.config.RecruitConfig;
import org.vectrics.recruiter.job.JobSearchCriteria;
import org.vectrics.recruiter.job.JobStatusType;
import org.vectrics.recruiter.struts.tag.JobDetailDisplayOptions;
import org.vectrics.struts.Request;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;


/**
 * @author mmoore
 */
public class ShowAdminIndex extends VectricsStrutsAction {
	private transient static Log log = LogFactory.getLog(ShowAdminIndex.class);
	
	public ShowAdminIndex() {
		super();
	}
	
	public String doExecute(VectricsActionData actionData)	throws JspException {
		log.debug("entering ShowAdminIndex()");
		String forward = "success";
		initialize(actionData.getRequest());
		
		return (forward);
	}

	public static void initialize(Request request) {
		Domain domain = ThreadProperties.getDomain();
		JobSearchCriteria criteria = new JobSearchCriteria();
		
		criteria.addStatusTypeCode(JobStatusType.STATUS_POSTED);
		
		log.debug("setting up job list criteria and display options");
		JobSearchActionHelper helper = new JobSearchActionHelper();
		helper.storeCriteria(request, criteria);
		
		JobDetailDisplayOptions displayOptions = new JobDetailDisplayOptions();
		displayOptions.setShowCompany(true);
		
		if (RecruitConfig.getRecruitInstance().getShowCompactJobListCompanyCode(domain) == true)
			displayOptions.setShowCompanyCode(true);
		else
			displayOptions.setShowCompanyCode(false);
		
		if (RecruitConfig.getRecruitInstance().getShowCompactJobListIcon(domain) == true)
			displayOptions.setShowActiveIndicator(true);
		else
			displayOptions.setShowActiveIndicator(false);
		
		
		if (RecruitConfig.getRecruitInstance().getShowCompactJobListReferenceCode(domain) == true)
			displayOptions.setShowReferenceCode(true);
		else
			displayOptions.setShowReferenceCode(false);
		
		helper.storeDisplayOptions(request, displayOptions);
	}

}
